var ctx;
var canvas;
var pbutton;
var gmesg;
var mmesg;
var medallist;

function pButtonClicked(){
    if(pbutton.innerHTML == "||"){
        pbutton.innerHTML = ">";
        gmesg.innerHTML = "<b> Paused </b>";
        gmesg.style.visibility = 'visible';
        data.snd_bg.pause();
    }else if(pbutton.innerHTML == "&gt;"){
        pbutton.innerHTML = "||";
        gmesg.style.visibility = 'hidden';
        data.snd_bg.play();
    }
}

function InitScreen(name){
    canvas = document.getElementById(name);
    if(!canvas){
        alert('Could not get Canvas');
        return;
    }   
    ctx = canvas.getContext('2d');
    //ctx.fillText("Loading... ", canvas.width/2, canvas.height/2);
    pbutton = document.getElementById("pbutton");
    pbutton.style.top = canvas.offsetTop;
    pbutton.style.left = canvas.offsetLeft + canvas.width - parseInt(pbutton.style.width);

    gmesg = document.getElementById("gmesg");
    gmesg.style.top =  canvas.offsetTop + canvas.height/2 - parseInt(gmesg.style.height);
    gmesg.style.left = canvas.offsetLeft;
    gmesg.innerHTML = "<b> Loading.. </b>";

    mmesg = document.getElementById("medal");
    mmesg.style.top = canvas.offsetTop + canvas.height - parseInt(mmesg.style.height);
    mmesg.style.left = canvas.offsetLeft + canvas.width - parseInt(mmesg.style.width);
    mmesg.style.visibility = "hidden";

    medallist = document.getElementById("medallist");
   
    var fbdiv = document.getElementById('fb');
    fbdiv.style.top = medallist.offsetTop;
    fbdiv.style.left = medallist.offsetLeft + canvas.width - 115; 

    //console.log("hello world");
    var gm = new Game();
    canvas.onmousemove = gm.onMouseMove;
    canvas.onmouseup = gm.onMousePress;
    setInterval(gm.update, 33);
}

